package cn.tedu.exam1.plan.service.impl;


import cn.tedu.exam1.plan.mapper.PlanMapper;
import cn.tedu.exam1.plan.pojo.dto.PlanQuery;
import cn.tedu.exam1.plan.pojo.dto.PlanSavaParam;
import cn.tedu.exam1.plan.pojo.entity.Plan;
import cn.tedu.exam1.plan.pojo.vo.PlanVO;
import cn.tedu.exam1.plan.service.PlanService;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Slf4j
@Service
public class PlanServiceImpl implements PlanService {
    @Autowired
    PlanMapper planMapper;

    @Override
    public void addPlan(PlanSavaParam planSavaParam) {
        Plan plan = new Plan();
        BeanUtils.copyProperties(planSavaParam,plan);
        plan.setPlanStatus("0");
        plan.setCreatTime(new Date());
        planMapper.addPlan(plan);
    }

    @Override
    public List<PlanVO> selectById(PlanQuery planQuery) {
        List<PlanVO> list = planMapper.selectById(planQuery);
        return list;
    }

    @Override
    public void update(PlanSavaParam planSavaParam) {
        planMapper.update(planSavaParam);
    }

    @Override
    public void delete(Long id) {
        planMapper.delete(id);
    }

    @Override
    public void updateStatus(Long userId) {
        planMapper.updateStatus(userId);
    }


//    @Override
//    public PlanVO selectByExam(ExamQuery examQuery) {
//        PlanVO planVO = planMapper.selectByExam(examQuery);
//        return planVO;
//    }
}
